package com.spbl.common;

import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.crypto.hash.SimpleHash;

/**
 * Description(密码加密)
 * author: Gao xueyong
 * Create at: 2020/6/13 10:21 上午
 */
@Slf4j
public class PasswordEncryptUtil {

    /**
     * 密码加密
     * @param password
     * @param salt 加盐值
     * @return
     */
    public static String encryPassword(String password,String salt) {
//        Md5Hash md5Hash = new Md5Hash(password,salt,ConstantUtil.hashIterations);
        String encodedPassword = new SimpleHash(ConstantUtil.hashAlgorithmName, password, salt, ConstantUtil.hashIterations).toString();
//        log.info("md5Hash.toHex() = {}",md5Hash.toHex());
//        log.info("encodedPassword = {}",encodedPassword);
//        log.info("md5Hash.toString() = {}",md5Hash.toString());
        return encodedPassword;
    }
}
